<?php namespace Phpcmf\Controllers;

class Son extends \Phpcmf\Home\Mform
{

    public function index() {
        $this->_Home_Show();
    }

    public function show() {
        $this->_Home_Show();
    }
	
	public function tan() {
	    $this->_Home_Show_tanchuang();
	}
	/**
	 * 收藏
	 */
	public function quan() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->run(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 置顶
	 */
	public function zhiding() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$this->member['is_admin'];
		//dr_debug('is_admin', $this->member['is_admin']);
		$rt = \Phpcmf\Service::M('op', 'quan')->zhiding(SITE_ID.'_'.MOD_DIR.$mid, $mid, $this->member['is_admin']);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 精华
	 */
	public function jinghua() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$this->member['is_admin'];
		dr_debug('is_admin', $this->member['is_admin']);
		$rt = \Phpcmf\Service::M('op', 'quan')->jinghua(SITE_ID.'_'.MOD_DIR.$mid, $mid, $this->member['is_admin']);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 全站置顶
	 */
	public function qzzd() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$this->member['is_admin'];
		dr_debug('is_admin', $this->member['is_admin']);
		$rt = \Phpcmf\Service::M('op', 'quan')->qzzd(SITE_ID.'_'.MOD_DIR.$mid, $mid, $this->member['is_admin']);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 首页置顶
	 */
	public function shouyezhiding() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$this->member['is_admin'];
		//dr_debug('is_admin', $this->member['is_admin']);
		$rt = \Phpcmf\Service::M('op', 'quan')->shouyezhiding(SITE_ID.'_'.MOD_DIR.$mid, $mid, $this->member['is_admin']);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 核对帖子
	 */
	public function shenhe() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$this->member['is_admin'];
		dr_debug('is_admin', $this->member['is_admin']);
		$rt = \Phpcmf\Service::M('op', 'quan')->shenhe(SITE_ID.'_'.MOD_DIR.$mid, $mid, $this->member['is_admin']);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 点赞
	 */
	public function zan() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->zan(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	/**
	 * 点赞列表
	 */
	public function zanlian() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->zan(SITE_ID.'_'.MOD_DIR.$mid, $mid, $id);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * jindu
	 */
	public function jindu() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->jindu(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//排期
	public function jindupaiqi() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->jindupaiqi(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//开发
	public function jindukaifa() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->jindukaifa(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//完成
	public function jinduwancheng() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->jinduwancheng(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//新增完成进度
	public function jindudata() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->jindudata(SITE_ID.'_'.MOD_DIR.$mid, $mid,$this->member['is_admin']);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//新增bug完成进度
	public function bugdata() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->bugdata(SITE_ID.'_'.MOD_DIR.$mid, $mid,$this->member['is_admin']);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	/**
	 * BUG
	 */
	public function bug() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->bug(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//bug排期
	public function bugpaiqi() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->bugpaiqi(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//bug开发
	public function bugkaifa() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->bugkaifa(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//bug完成
	public function bugwancheng() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->bugwancheng(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	
	//pk蓝方
	public function pk() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$pkfang = (int)\Phpcmf\Service::L('input')->get('pkfang');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->pk(SITE_ID.'_'.MOD_DIR.$mid, $pkfang, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//pk不通过
	public function pkbutong() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$pkfang = (int)\Phpcmf\Service::L('input')->get('pkfang');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->pkbutong(SITE_ID.'_'.MOD_DIR.$mid, $pkfang, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//pk删除
	public function pkshanchu() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$pkfang = (int)\Phpcmf\Service::L('input')->get('pkfang');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->pkshanchu(SITE_ID.'_'.MOD_DIR.$mid, $pkfang, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//pk通过
	public function pktongguo() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$pkfang = (int)\Phpcmf\Service::L('input')->get('pkfang');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->pktongguo(SITE_ID.'_'.MOD_DIR.$mid, $pkfang, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//出租
	public function chuzu() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$chuzu = (int)\Phpcmf\Service::L('input')->get('chuzu');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->chuzu(SITE_ID.'_'.MOD_DIR.$mid, $chuzu, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//求租
	public function qiuzu() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$qiuzu = (int)\Phpcmf\Service::L('input')->get('qiuzu');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->qiuzu(SITE_ID.'_'.MOD_DIR.$mid, $qiuzu, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//招聘
	public function zhaopin() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$zhaopin = (int)\Phpcmf\Service::L('input')->get('zhaopin');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->zhaopin(SITE_ID.'_'.MOD_DIR.$mid, $zhaopin, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//求职
	public function qiuzhi() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$qiuzhi = (int)\Phpcmf\Service::L('input')->get('qiuzhi');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->qiuzhi(SITE_ID.'_'.MOD_DIR.$mid, $qiuzhi, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	//投票
	public function toupiao() {
	    $id = (int)\Phpcmf\Service::L('input')->get('id');
		$value = (int)\Phpcmf\Service::L('input')->get('value');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', MOD_DIR)->toupiao(SITE_ID.'_'.MOD_DIR.$mid, $value, MOD_DIR, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	/**
	 * 下载
	 */
	public function xiazaicishu() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->xiazaicishu(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 短信已读
	*/
	public function yidu() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->yidu(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    //$rt = \Phpcmf\Service::M('op', 'quan')->run($this->tablename, $id);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 申请副圈主
	*/
	public function fuquanzhu() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->fuquanzhu(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}
	/**
	 * 管理圈主组
	*/
	public function guanlizu() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->guanlizu(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	} 
	/**
	 * 管理圈主组状态
	*/
	public function guanlizuzhuangtai() {
	    //$id = (int)\Phpcmf\Service::L('input')->get('id');
		$this->_module_init($mid);
		$rt = \Phpcmf\Service::M('op', 'quan')->guanlizuzhuangtai(SITE_ID.'_'.MOD_DIR.$mid, $mid);
	    $this->_json($rt['code'], $rt['msg'], $rt['data'], $rt['datas']);
	}

    protected function _Call_Show($data) {

        $_test_0 = 0;
        $_test_1 = [];
        $data['prev_page'] = $data['next_page'] = [];

        $son = \Phpcmf\Service::M()->table(SITE_ID.'_'.MOD_DIR.'_form_son')
            ->where('cid', $data['cid'])
            ->where('status=1')
            ->order_by('displayorder asc,id asc')->getAll();
        if ($son) {
            foreach ($son as $i => $t) {
                $son[$i]['url'] = dr_son_url($t);
                if ($t['id'] == $data['id']) {
                    // 找到了
                    $_test_0 = 1;
                    $data['prev_page'] = $_test_1;
                } elseif ($_test_0) {
                    $_test_0 = 0;
                    $data['next_page'] = $son[$i];
                }
                $_test_1 = $son[$i];
            }
        }

        $data['cneirong'] = dr_strcut(dr_clearhtml($data['neirong']), 100);
        $data['son_list'] = \Phpcmf\Service::M('content', 'quan')->format_son_list($son, $this->index['son_type']);
        $data['son_type'] = \Phpcmf\Service::M('content', 'quan')->format_son_type($this->index['son_type']);
        $data['ctitle'] = $this->index['title'];
        $data['tname'] = $data['son_type'][$data['tid']];

        return $data;
    }
}
